//
//  UIStoryboard+SYAdd.m
//  huisaoche
//
//  Created by Steven.Yung on 2017/6/28.
//  Copyright © 2017年 Minidai. All rights reserved.
//

#import "UIStoryboard+SYAdd.h"

@implementation UIStoryboard (SYAdd)

+ (id)viewControllerWithIdentifier:(NSString *)identifier {
    
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:identifier bundle:nil];
    
    NSString *string = [NSString stringWithFormat:@"找不到%@的storyboard，请检查你的storyboard", identifier];
    NSAssert(storyboard, string);
    
    UIViewController *viewController = [storyboard instantiateInitialViewController];
    if (!viewController) {
        viewController = [storyboard instantiateViewControllerWithIdentifier:identifier];
    }
    
    string = [NSString stringWithFormat:@"找不到%@的ViewController, 请确保你的storyboard已设置了is initial ViewController或者Storyboard ID", identifier];
    NSAssert(viewController, string);
    
    return viewController;
}

@end
